from dataclasses import dataclass
from datetime import datetime

from .model import GPTModelHparams
from .training import GPTTrainingHparams


@dataclass(kw_only=True)
class GPTLaunchingHparams:
    model: GPTModelHparams
    training: GPTTrainingHparams


def make_training_name(hparams: GPTLaunchingHparams | None = None) -> str:
    parts = ["training", datetime.now().strftime("%Y%m%d-%H%M%S-%f")]
    if hparams is not None:
        if hparams.model.name is not None:
            parts.append(hparams.model.name)
        if hparams.training.name is not None:
            parts.append(hparams.training.name)
    return "_".join(parts)
